import yaml
import urllib.parse

cookie = ''

config = {}

def loadInfoByFile(yaml_file_path):
    with open('./config/cookie', 'r') as f:
        lines = f.readlines()
        global cookie
        cookie = lines[0]


    # 读取并解析YAML文件
    with open(yaml_file_path, 'r', encoding='utf-8') as file:
        global config
        config = yaml.safe_load(file)

def getCookie():
    return cookie

def getCookieDeict():
    cookie_dict = {}
    for cookie_pair in cookie.split(';'):
        key, value = cookie_pair.split('=', 1)
        cookie_dict[key] = urllib.parse.unquote(value)

def getConfig(key):
    return config[key]